package components;

import java.util.*;

import uml.Visitable;
import uml.Visitor;

public class Method implements Visitable {
	private String accessQualifier;
	private String name;
	private String returnedType;
	private String _static;
	private String _final;
	private String _synchronized;
	private String _abstract;
	private boolean constructor = false;
	
	private HashMap<String,Argument> arguments = new HashMap<String,Argument>();
	
	public Method(){}
	
	public Method(String name){
		this.name = name;
	}
	
	public void setName(String name){
		this.name = name;
	}
	
	public String getName(){
		return name;
	}
	
	public void addArgument(Argument argument){
		arguments.put(argument.toString(), argument);
	}
	
	public String getAccessQualifier() {
		return accessQualifier;
	}

	public void setAccessQualifier(String accessQualifier) {
		this.accessQualifier = accessQualifier;
	}

	public String getReturnedType() {
		return returnedType;
	}

	public void setReturnedType(String returnedType) {
		this.returnedType = returnedType;
	}
	
	public String getStatic() {
		return _static;
	}

	public void setStatic(String _static) {
		this._static = _static;
	}

	public String getFinal() {
		return _final;
	}

	public void setFinal(String _final) {
		this._final = _final;
	}

	public String getSynchronized() {
		return _synchronized;
	}

	public void setSynchronized(String _synchronized) {
		this._synchronized = _synchronized;
	}

	public String getAbstract() {
		return _abstract;
	}

	public void setAbstract(String _abstract) {
		this._abstract = _abstract;
	}

	public String toString(){
		StringBuilder sb = new StringBuilder();
		
		for(String a : arguments.keySet()){
			sb.append(a + ",");
		}
		if(sb.length() > 0)
			sb.deleteCharAt(sb.length()-1);
		return accessQualifier + " " + _abstract + " " + _static + " " + _final + " " + _synchronized + " " + returnedType + " " + name + "(" + sb + ")";
	}

	public boolean isConstructor() {
		return constructor;
	}

	public void setConstructor(boolean constructor) {
		this.constructor = constructor;
	}

	@Override
	public void accept(Visitor visitor) {
		visitor.visit(this);
	}

	public void setArguments(HashMap<String,Argument> arguments) {
		this.arguments = arguments;
	}

	public HashMap<String,Argument> getArguments() {
		return arguments;
	}	
}
